package com.jwthhealth_pub.old.sportfitness.view.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.jwthhealth_pub.R;
import com.jwthhealth_pub.old.common.ImageLoader;
import com.jwthhealth_pub.old.sportfitness.view.SportCourseListActivity;

import java.util.List;

/**
 * Created by Administrator on 2017/1/6.
 */
public class SportItemFootHorAdapter extends RecyclerView.Adapter {

    SportCourseListActivity activity;
    List<String> list;

    public SportItemFootHorAdapter(SportCourseListActivity sportCourseListActivity, List<String> thumb_list) {
        this.activity = sportCourseListActivity;
        this.list = thumb_list;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(activity, R.layout.item_img, null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ViewHolder viewHolder = (ViewHolder) holder;
//        Picasso.with(activity).load(list.get(position)).into(viewHolder.img);
        ImageLoader.picasso(list.get(position), viewHolder.img);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{

        ImageView img;

        public ViewHolder(View itemView) {
            super(itemView);
            img = (ImageView) itemView.findViewById(R.id.img);
        }
    }
}
